#!/bin/bash

FRAPPE_BRANCH=${1}

[ "${FRAPPE_BRANCH}" ] && FRAMEWORK_BRANCH="-b ${FRAPPE_BRANCH}"

mkdir -p /home/frappe/frappe-bench/sites/assets
cd /home/frappe/frappe-bench
mkdir -p apps
cd apps
git clone --depth 1 https://gitee.com/eanfs32/frappe frappe ${FRAMEWORK_BRANCH}

echo -e "frappe" > /home/frappe/frappe-bench/sites/apps.txt

cd /home/frappe/frappe-bench/apps/frappe 

# yarn config set registry https://registry.npm.taobao.org
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g 
yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs/ -g

yarn --pure-lockfile
yarn production

echo "rsync -a --delete /var/www/html/assets/frappe /assets" > /rsync
